window.onload = function(){
	var oUl = document.getElementById('lb');
	var aLiUl = oUl.getElementsByTagName('li');
	
	var oOl = document.getElementById('lb-list');
	var aLiOl = oOl.getElementsByTagName('li');
	
	var oBox = document.getElementById('box');
	var iNow = 0; 
	for(var i=0;i<aLiOl.length;i++){
		aLiOl[i].index = i;
		aLiOl[i].onmousedown = function(){
			for(var i=0;i<aLiOl.length;i++){
				aLiOl[i].className = '';
				startMove(aLiUl[i],{opacity:0},function(){
					this.style.display = 'none';	
			} );
				
			}
			this.className = 'active';
			aLiUl[this.index].style.display = 'block';
			iNow = this.index;
			startMove(aLiUl[this.index],{opacity:100});
		};
	}

	var timer = null;

	timer = setInterval(toRun,2000);

    oBox.onmouseover = function(){
    	clearInterval(timer);
    }
    
    oBox.onmouseout= function(){
    	timer = setInterval(toRun,2000);
    }
	function toRun(){
		if(iNow == aLiOl.length-1){
			iNow = 0;
		}
		else{
			iNow++;
		}
		for(var i=0;i<aLiOl.length;i++){
			aLiOl[i].className = '';
			startMove(aLiUl[i],{opacity:0},function(){
					this.style.display = 'none';	
			} );

		}
		aLiOl[iNow].className = 'active'; 
		aLiUl[iNow].style.display = 'block';
		startMove(aLiUl[iNow],{opacity:100});

	}
};